
package com.kanjian.music.api;

import java.util.Arrays;
import java.util.HashMap;

import android.text.TextUtils;

// Api http请求
public class ApiRequestManager {

    private ApiRequestManager() {
    }

    // 登陆
    public static RequestEntity getLoginRequest(String uName, String pwd) {
        HashMap<String, String> params = new HashMap<String, String>(3);
        params.put("username", uName);
        params.put("password", pwd);
        return ApiURL.fixSid(new RequestEntity(ApiURL.spellUrl(ApiURL.URL_ACTION_LOGIN), params));
    }

    // 获取banner
    public static RequestEntity getBannerRequest() {
        return ApiURL.fixSid(new RequestEntity(ApiURL.spellUrl(ApiURL.URL_ACTION_GET_BANNER)));
    }

    // 你可能喜欢
    public static RequestEntity getMayLikeRequest(boolean isOther) {
        return ApiURL.fixSid(new RequestEntity(ApiURL.spellUrl(ApiURL.URL_ACTION_MAY_LIKE)
                + "?other=" + (isOther ? 0 : 1)));
    }

    // 编辑推荐
    public static RequestEntity getRecommendRequest(boolean isOther) {
        return ApiURL.fixSid(new RequestEntity(ApiURL.spellUrl(ApiURL.URL_ACTION_RECOMMEND)
                + "?other=" + (isOther ? 0 : 1)));
    }

    // 精选单曲
    public static RequestEntity getNiceRequest() {
        // return new RequestEntity(ApiURL.spellUrl(ApiURL.URL_ACTION_NICE));
        return ApiURL.fixSid(new RequestEntity(ApiURL.spellUrl(ApiURL.URL_ACTION_NICE)));
    }

    // 榜单首页
    public static RequestEntity getRankTitle() {
        return ApiURL.fixSid(new RequestEntity(ApiURL.spellUrl(ApiURL.URL_ACTION_RANKING_TITLE)));
    }

    // 榜单详情
    public static RequestEntity getRankDetailRequest(String rankType) {
        return ApiURL.fixSid(new RequestEntity(ApiURL.spellUrl(ApiURL.URL_ACTION_RANK_DETAIL)
                + "?type=" + rankType));
    }

    // 我喜欢的歌曲
    public static RequestEntity getMyFavorteRequest() {
        return ApiURL.fixSid(new RequestEntity(ApiURL.spellUrl(ApiURL.URL_ACTION_MY_FAVORTE)));
    }

    // 电台列表
    public static RequestEntity getRadioRequest(int type) {
        return ApiURL.fixSid(new RequestEntity(ApiURL.spellUrl(ApiURL.URL_ACTION_RADIO) + "?type="
                + type));
    }

    // 删除电台歌曲
    public static RequestEntity getDelRadioMusicRequest(int musicId, int type) {
        HashMap<String, String> params = new HashMap<String, String>(3);
        params.put("mid", musicId + "");
        params.put("type", type + "");
        return ApiURL.fixSid(new RequestEntity(ApiURL.spellUrl(ApiURL.URL_ACTION_DEL_RADIO_MUSIC),
                params));
    }

    // 邂逅
    public static RequestEntity getFeedRequest(int pageIndex) {
        return ApiURL.fixSid(new RequestEntity(ApiURL.spellUrl(ApiURL.URL_ACTION_FEED) + "?more="
                + pageIndex));
    }

    // 直播活动列表
    public static RequestEntity getActivityRequest() {
        return ApiURL.fixSid(new RequestEntity(ApiURL.spellUrl(ApiURL.URL_ACTION_ACTIVITY)));
    }

    // 下次直播活动
    public static RequestEntity getNextActivityRequest(int userId) {
        return ApiURL.fixSid(new RequestEntity(ApiURL.spellUrl(ApiURL.URL_ACTION_NEXT_ACTIVITY)
                + "?uid=" + userId));
    }

    // 活动公告详情
    public static RequestEntity getActivityDetailRequest(String activityId) {
        return ApiURL.fixSid(new RequestEntity(ApiURL.spellUrl(ApiURL.URL_ACTION_ACTIVITY_DETAIL)
                + "?aid=" + activityId));
    }

    // 直播间用户列表
    public static RequestEntity getRoomUserListRequest(int roomId, int pageIndex) {
        return ApiURL.fixSid(new RequestEntity(ApiURL.spellUrl(ApiURL.URL_ACTION_USER_LIST)
                + "?room_id=" + roomId + "&page=" + pageIndex));
    }

    // 直播间状态
    public static RequestEntity getRoomStatusRequest(int roomId) {
        return ApiURL.fixSid(new RequestEntity(ApiURL.spellUrl(ApiURL.URL_ACTION_ROOM_STATUS)
                + "?room_id=" + roomId));
    }

    // 注册
    public static RequestEntity getRegisterRequest(String uName, String pwd) {
        HashMap<String, String> params = new HashMap<String, String>(4);
        params.put("username", uName);
        params.put("password", pwd);
        params.put("argee", "0");
        return ApiURL
                .fixSid(new RequestEntity(ApiURL.spellUrl(ApiURL.URL_ACTION_REGISTER), params));
    }

    // 检查用户名
    public static RequestEntity getCheckUserNameRequest(String uName) {
        HashMap<String, String> params = new HashMap<String, String>(2);
        params.put("username", uName);
        return ApiURL.fixSid(new RequestEntity(ApiURL.spellUrl(ApiURL.URL_ACTION_CHECK_USERNAME),
                params));
    }

    // 第三方注册登录
    public static RequestEntity getOpenRegisterRequest(String openId, String from,
            String accessToken, String expireTime, String uName) {
        HashMap<String, String> params = new HashMap<String, String>();
        params.put("username", uName);
        params.put("openId", openId);
        params.put("login_from", from);
        params.put("accessToken", accessToken);
        params.put("expireTime", expireTime + "");
        return ApiURL.fixSid(new RequestEntity(ApiURL.spellUrl(ApiURL.URL_ACTION_REGISTER_OPEN),
                params));
    }

    // 修改头像

    // 获取音乐基因
    public static RequestEntity getGeneRequest() {
        return ApiURL.fixSid(new RequestEntity(ApiURL.spellUrl(ApiURL.URL_ACTION_GENE)));
    }

    // 设置音乐基因
    public static RequestEntity getSetGenRequest(String geneArray) {
        if (!TextUtils.isEmpty(geneArray)) {
            HashMap<String, String> params = new HashMap<String, String>(2);
            params.put("type_list", geneArray);
            return ApiURL
                    .fixSid(new RequestEntity(ApiURL.spellUrl(ApiURL.URL_ACTION_GENE), params));
        }
        return null;
    }

    // 喜欢歌
    public static RequestEntity getDoLikeRequest(long... musicIdArray) {
        if (musicIdArray != null && musicIdArray.length > 0) {
            HashMap<String, String> params = new HashMap<String, String>(3);
            params.put("action", "0");
            params.put("mid", Arrays.toString(musicIdArray).replaceAll("\\[|\\]| ", ""));
            return ApiURL.fixSid(new RequestEntity(ApiURL.spellUrl(ApiURL.URL_ACTION_DO_LIKE),
                    params));
        }
        return null;
    }

    // 取消喜欢
    public static RequestEntity getCancelLikeRequest(long... musicIdArray) {
        if (musicIdArray != null && musicIdArray.length > 0) {
            HashMap<String, String> params = new HashMap<String, String>(3);
            params.put("action", "1");
            params.put("mid", Arrays.toString(musicIdArray).replaceAll("\\[|\\]| ", ""));
            return ApiURL.fixSid(new RequestEntity(ApiURL.spellUrl(ApiURL.URL_ACTION_DO_LIKE),
                    params));
        }
        return null;
    }

    // 获取关注的音乐人
    public static RequestEntity getFollowRequest(int pageIndex) {
        return ApiURL.fixSid(new RequestEntity(ApiURL.spellUrl(ApiURL.URL_ACTION_FOLLOW) + "?more="
                + pageIndex));
    }

    // 消息中心
    public static RequestEntity getMessageRequest() {
        return null;
    }

    // 版本检查
    public static RequestEntity getVersionRequest(String ver) {
        return ApiURL.fixSid(new RequestEntity(ApiURL.spellUrl(ApiURL.URL_ACTION_VER) + "?ver="
                + ver));
    }

    // 意见反馈
    public static RequestEntity getFeedbackRequest(String content, String connect) {
        HashMap<String, String> params = new HashMap<String, String>(3);
        params.put("option", content);
        params.put("connect", connect);
        return ApiURL
                .fixSid(new RequestEntity(ApiURL.spellUrl(ApiURL.URL_ACTION_FEEDBACK), params));
    }

    // 搜索
    public static RequestEntity getSearchRequest(String tag, String key, int pageIndex) {
        return ApiURL.fixSid(new RequestEntity(ApiURL.spellUrl(ApiURL.URL_ACTION_SEARCH) + "?tag="
                + tag + "&keyword=" + key + "&more=" + pageIndex));
    }

    // 相似歌曲
    public static RequestEntity getSimilarMusicRequest(int musicId, int pageIndex) {
        return ApiURL.fixSid(new RequestEntity(ApiURL.spellUrl(ApiURL.URL_ACTION_SIMILAR_MUSIC)
                + "?mid=" + musicId + "&more=" + pageIndex));
    }

    // 歌曲详情
    public static RequestEntity getSongRequest(int musicId) {
        return ApiURL.fixSid(new RequestEntity(ApiURL.spellUrl(ApiURL.URL_ACTION_SONG) + "?mid="
                + musicId));
    }

    // 音乐人详情
    public static RequestEntity getMusicianRequest(int userId) {
        return ApiURL.fixSid(new RequestEntity(ApiURL.spellUrl(ApiURL.URL_ACTION_MUSICIAN)
                + "?uid=" + userId));
    }

    // 关注音乐人
    public static RequestEntity getDoFollowRequest(int userId) {
        HashMap<String, String> params = new HashMap<String, String>(3);
        params.put("uid", userId + "");
        params.put("action", "0");
        return ApiURL
                .fixSid(new RequestEntity(ApiURL.spellUrl(ApiURL.URL_ACTION_DO_FOLLOW), params));
    }

    // 取消关注音乐人
    public static RequestEntity getCancelFollowRequest(int userId) {
        HashMap<String, String> params = new HashMap<String, String>(3);
        params.put("uid", userId + "");
        params.put("action", "1");
        return ApiURL
                .fixSid(new RequestEntity(ApiURL.spellUrl(ApiURL.URL_ACTION_DO_FOLLOW), params));
    }

    // 退出登陆
    public static RequestEntity getLogoutRequest() {
        HashMap<String, String> params = new HashMap<String, String>(1);
        return ApiURL.fixSid(new RequestEntity(ApiURL.spellUrl(ApiURL.URL_ACTION_LOGOUT), params));
    }

}
